package com.dhcc.bpm.alarm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.alarm.entity.AlarmFtpInfoConfig;
import com.dhcc.bpm.alarm.service.IAlarmFtpInfoConfigService;
import com.dhcc.bpm.alarm.vo.AlarmFtpInfoConfigVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 *  控制器
 *
 * @author xiafayu
 * @since 2022-02-16
 */
@RestController
@AllArgsConstructor
@NoArgsConstructor
@RequestMapping("alarm/alarmFtpInfoConfig")
@Api(value = "FTP参数表", tags = "接口")
public class AlarmFtpInfoConfigController extends BladeController {
	@Autowired
	private IAlarmFtpInfoConfigService alarmFtpInfoConfigService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入alarmFtpInfoConfig")
	public R<AlarmFtpInfoConfig> detail(AlarmFtpInfoConfig alarmFtpInfoConfig) {
		AlarmFtpInfoConfig detail = alarmFtpInfoConfigService.getOne(Condition.getQueryWrapper(alarmFtpInfoConfig));
		return R.data(detail);
	}

	/**
	 * 分页 
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入alarmFtpInfoConfig")
	public R<IPage<AlarmFtpInfoConfig>> list(AlarmFtpInfoConfig alarmFtpInfoConfig, Query query) {
		IPage<AlarmFtpInfoConfig> pages = alarmFtpInfoConfigService.page(Condition.getPage(query), Condition.getQueryWrapper(alarmFtpInfoConfig));
		return R.data(pages);
	}

	/**
	 * 自定义分页 
	 */
	@GetMapping("/qryList")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes = "传入alarmFtpInfoConfig")
	public R<IPage<AlarmFtpInfoConfigVO>> page(AlarmFtpInfoConfigVO alarmFtpInfoConfig, Query query) {
		IPage<AlarmFtpInfoConfigVO> pages = alarmFtpInfoConfigService.selectAlarmFtpInfoConfigPage(Condition.getPage(query), alarmFtpInfoConfig);
		return R.data(pages);
	}

	/**
	 * 新增 
	 */
	@PostMapping("/add")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes = "传入alarmFtpInfoConfig")
	public R save(@Valid @RequestBody AlarmFtpInfoConfig alarmFtpInfoConfig) {
		return R.status(alarmFtpInfoConfigService.save(alarmFtpInfoConfig));
	}

	/**
	 * 修改 
	 */
	@PostMapping("/edit")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes = "传入alarmFtpInfoConfig")
	public R update(@Valid @RequestBody AlarmFtpInfoConfig alarmFtpInfoConfig) {
		return R.status(alarmFtpInfoConfigService.updateById(alarmFtpInfoConfig));
	}

	/**
	 * 新增或修改 
	 */
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改", notes = "传入alarmFtpInfoConfig")
	public R submit(@Valid @RequestBody AlarmFtpInfoConfig alarmFtpInfoConfig) {
		return R.status(alarmFtpInfoConfigService.saveOrUpdate(alarmFtpInfoConfig));
	}

	
	/**
	 * 删除 
	 */
	@PostMapping("/remove")
	@ApiOperationSupport(order = 8)
	@ApiOperation(value = "删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(alarmFtpInfoConfigService.removeByIds(Func.toLongList(ids)));
	}


	/**
	 * 服务器测试连接
	 */
	@PostMapping("/testConnection")
	@ApiOperationSupport(order = 9)
	@ApiOperation(value = "测试连接", notes = "传入alarmFtpInfoConfig")
	public Object testConnection(@Valid @RequestBody AlarmFtpInfoConfig alarmFtpInfoConfig) {
		return alarmFtpInfoConfigService.testConnection(alarmFtpInfoConfig);
	}





}
